
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports _2bMatesSite.BO

Namespace _2bMatesSite
	''' <summary>
	''' Summary description for terms.
	''' </summary>
	Public Partial Class view_message
		Inherits BaseWebPage
		Protected MessageID As Integer
		Protected SenderID As Integer
		Protected MessageType As String
		Protected MessageBox As String = Messages.BoxType.btInbox.ToString()
		Protected boxType As String = ""
		Protected grpID As Integer = -1
		Protected isGroupMode As Boolean = False
		Protected isUserMode As Boolean = False
		' true - prev page is user messages, false - prev page is group messages
		Protected grp As Group = Nothing
		Protected isModerator As Boolean = False
		Protected bIsGroupBulletin As Boolean = False
		Private bShowSentFromCurrUserMsg As Boolean = False
		Private sRecipientName As String = ""
		Protected hlInbox As System.Web.UI.WebControls.HyperLink
		Protected hlSent As System.Web.UI.WebControls.HyperLink
		Protected hlTrash As System.Web.UI.WebControls.HyperLink
		Protected hlConfirmFriends As System.Web.UI.WebControls.HyperLink
		Protected htPageConstants As New Hashtable()
		Protected msgType As Integer = -1
		'protected string onClickJS = "";

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
			Dim parentPage As String = Request.ServerVariables("HTTP_REFERER")
			'onClickJS = "document.getElementById('" + trUserCanceledMessage.UniqueID.Replace(":", "_") + "').className='visible';";
			Dim prevMessage As Message = Nothing
			Dim nextMessage As Message = Nothing

			' Auto login from an external link
			'AutoLogin( Request );

			' Put user code to initialize the page here
			' this.pageTemplate.PageTitle = PageTitles.VIEW_MESSAGE_PAGE;
			Dim usr As User = LoggedUser
			If usr = Nothing Then
				Common.Utils.RedirectToLoginPage(Page)
			End If

			Me.initPageTitles(Constants.VIEW_MESSAGE, "", Form1, Nothing, htPageConstants)
			Me.initAdvertisements(Form1, Nothing)

			If parentPage = Nothing Then
				parentPage = ""
			Else
				parentPage = parentPage.ToString()
			End If

			bShowSentFromCurrUserMsg = parentPage.ToString().EndsWith(Constants.SENT_MESSAGE)

			If Request.Params(Constants.MSGBOX_PARAM) <> Nothing Then
				bShowSentFromCurrUserMsg = (Request.Params(Constants.MSGBOX_PARAM) = Constants.MSGBOX_SENT)
			End If

			If Request.Params(Constants.MSG_TYPE_PARAM) <> Nothing Then
				Try
					msgType = Convert.ToInt32(Request.Params(Constants.MSG_TYPE_PARAM).ToString())
				Catch
					Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
				End Try
				bIsGroupBulletin = (msgType = (DirectCast(Messages.MessageType.mtGroupBulletin, Integer)))
			End If

			'				if ( parentPage == null )
			'					if ( Request.Params[Constants.LOGIN_PARAM_USER] != null && Request.Params[Constants.LOGIN_PARAM_KEY] != null)
			'						parentPage = "";
			'					else
			'						throw new Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS);
			'				else
			'					parentPage = parentPage.ToString();

			' init group

			If Request.Params(Constants.GROUP_PARAM) <> Nothing AndAlso Request.Params(Constants.GROUP_PARAM) <> "" Then
				If Request.Params(Constants.USER_MODE_PARAM) <> Nothing AndAlso Request.Params(Constants.USER_MODE_PARAM) <> "" Then
					isUserMode = True
				End If
				Try
					isGroupMode = True
					grpID = Convert.ToInt32(Request.Params(Constants.GROUP_PARAM))
					grp = Groups.GetGroupByID(grpID)

					If grp = Nothing AndAlso Not isUserMode Then
						Throw New Exception(Constants.ERROR_MESSAGE_GROUP_DOESNT_EXIST_ERROR)
					End If
				Catch
					Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
				End Try
			End If

			If isGroupMode And Not isUserMode Then
				' init page title
				'litMainPageTitle.Text = "View Group Bulletin";
				litMainPageTitle.Text = GetPageConstText(htPageConstants, "CONST_MainPageTitle_TEXT")
				'"View Group Bulletin";
				' init menu to group
				grpBlogTabs.Visible = True
				ucTabs.Visible = False

				hlRightLink.Text = (Me.GetPageConstText(htPageConstants, "CONST_GroupBackLink_TEXT")).Replace("[PARAM]", grp.Name)
				hlRightLink.NavigateUrl = "../" + Constants.GROUP + "?" + Constants.GROUP_PARAM + "=" + grp.ID
			Else
				' init menu to user
				grpBlogTabs.Visible = False
				ucTabs.Visible = True

				hlRightLink.Visible = False
			End If

			' init message
			If Request.Params("id") <> Nothing Then
				Try
					MessageID = Convert.ToInt32(Request.Params("id"))
				Catch
					Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
				End Try

				Dim msg As Message = Nothing
				If isGroupMode Then
					If isUserMode Then
						msg = Messages.GetUserGroupBulletin(usr.ID, grpID, MessageID)
					Else
						msg = Messages.GetGroupBulletin(grpID, MessageID)
					End If
				Else
					If bIsGroupBulletin Then
						msg = Messages.GetUserGroupBulletin(usr.ID, -1, MessageID)
					Else
						msg = Messages.GetUserMessage(usr.ID, MessageID)
					End If
				End If

				If msg = Nothing Then
					Throw New Exception("This message is already deleted.")
				End If

				If (isGroupMode AndAlso Not isUserMode) AndAlso (grp.Uid <> usr.ID) Then
					btnDelete.Visible = False
					btnDeleteUp.Visible = False
				Else
					btnDelete.Visible = True
					btnDeleteUp.Visible = True
				End If

				SenderID = msg.SenderID
				msg.IsRead = True
				msg.Save()

				If bShowSentFromCurrUserMsg = False Then
					lblFrom.Text = Me.GetPageConstText(htPageConstants, "CONST_From_TEXT")

					Dim SenderPic As UserPicture = msg.Sender.DefaultPicture
					If SenderPic <> Nothing Then
						hlFromImage.ImageUrl = Pictures.GetPictureSrcFullURL(SenderPic, True, "../")
					Else
						hlFromImage.ImageUrl = "../images/default_thumbnail.gif"
					End If
					hlFromImage.ToolTip = msg.Sender.Name
					Dim LoggedUsersList As ArrayList = Common.Utils.GetLoggedUsersIDs()
					If LoggedUsersList.Contains(msg.SenderID) Then
						imgOnline.ImageUrl = "../images/online_status.gif"
					Else
						imgOnline.ImageUrl = "../images/spacer.gif"
					End If

					' added on 01/09/2004: "|| msg.Sender.Status == Users.STATUS_UNCONFIRMED" 		

					hlFromImage.NavigateUrl = Users.ComposeMemeberLink(msg.Sender)
					hlFromName.NavigateUrl = Users.ComposeMemeberLink(msg.Sender)
					hlFromImage.Attributes.Add("onclick", Users.ComposeMemeberLinkOnClickJS(msg.Sender, trUserCanceledMessage))
					hlFromName.Attributes.Add("onclick", Users.ComposeMemeberLinkOnClickJS(msg.Sender, trUserCanceledMessage))

					If msg.Sender.Status = Users.STATUS_LOCKED Then
						btnReply.Visible = False
						btnReplyUp.Visible = False
					End If
				Else

					'lblFrom.Text="To";
					lblFrom.Text = GetPageConstText(htPageConstants, "CONST_FromPageTitle_TEXT")
					'To
					Dim recipientsList As ArrayList
					Dim curRecipientID As Integer
					Dim curRecipient As User

					recipientsList = msg.Recipients

					Dim j As Integer = 0
					While j < recipientsList.Count
						curRecipientID = DirectCast(recipientsList(j), Integer)
						curRecipient = Users.GetUserByID(curRecipientID)

						sRecipientName = curRecipient.Name.ToString()

						Dim RecipientPic As UserPicture = curRecipient.DefaultPicture

						If RecipientPic <> Nothing Then
							hlFromImage.ImageUrl = Pictures.GetPictureSrcFullURL(RecipientPic, True, "../")
						Else
							hlFromImage.ImageUrl = "../images/default_thumbnail.gif"
						End If
						hlFromImage.ToolTip = curRecipient.Name
						Dim LoggedUsersList As ArrayList = Common.Utils.GetLoggedUsersIDs()
						If LoggedUsersList.Contains(curRecipient) Then
							imgOnline.ImageUrl = "../images/online_status.gif"
						Else
							imgOnline.ImageUrl = "../images/spacer.gif"
						End If

						' added on 01/09/2004: "|| msg.Sender.Status == Users.STATUS_UNCONFIRMED" 		
						'if(msg.Sender.Status == Users.STATUS_ACTIVE || msg.Sender.Status == Users.STATUS_UNCONFIRMED)

						hlFromImage.NavigateUrl = Users.ComposeMemeberLink(curRecipient)
						hlFromName.NavigateUrl = Users.ComposeMemeberLink(curRecipient)
						hlFromImage.Attributes.Add("onclick", Users.ComposeMemeberLinkOnClickJS(curRecipient, trUserCanceledMessage))
						hlFromName.Attributes.Add("onclick", Users.ComposeMemeberLinkOnClickJS(curRecipient, trUserCanceledMessage))

						If curRecipient.Status = Users.STATUS_LOCKED Then
							btnReply.Visible = False
							btnReplyUp.Visible = False
						End If
						System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
					End While
				End If

				' init box type
				If Not Me.IsPostBack Then
					If parentPage.IndexOf(Constants.VIEW_MESSAGE) = -1 AndAlso parentPage.IndexOf(Constants.WELCOME) = -1 Then
						If parentPage.IndexOf(Constants.INBOX) <> -1 Then
							boxType = Constants.MSGBOX_INBOX
						End If
						If parentPage.IndexOf(Constants.SENT_MESSAGE) <> -1 Then
								'hlInboxDown.NavigateUrl = ;
								'hlInboxDown.Text
							boxType = Constants.MSGBOX_SENT
						End If
						If parentPage.IndexOf(Constants.BULLETIN) <> -1 Then
							boxType = Constants.MSGBOX_BULLETIN
						End If
						If parentPage.IndexOf(Constants.MESSAGES_GROUP_BULLETIN) <> -1 Then
							boxType = Constants.MSGBOX_GROUP_BULLETIN
						End If
						If parentPage.IndexOf(Constants.TRASH) <> -1 Then
							boxType = Constants.MSGBOX_TRASH
						End If
					End If

					If boxType = String.Empty Then
						If Request.Params(Constants.MSGBOX_PARAM) <> Nothing Then
							boxType = Request.Params(Constants.MSGBOX_PARAM)
						Else
							boxType = Constants.MSGBOX_INBOX
							'throw new Exception( Constants.ERROR_MESSAGE_MISSING_PARAMETERS );
						End If
					End If
				Else
					If ViewState("boxType") <> Nothing Then
						boxType = ViewState("boxType").ToString()
					Else
						boxType = Constants.MSGBOX_INBOX
						'throw new Exception( Constants.ERROR_MESSAGE_MISSING_PARAMETERS );
					End If
				End If

				ViewState("boxType") = boxType

				ucTabs.PageName = Constants.VIEW_MESSAGE
				grpBlogTabs.PageName = Constants.VIEW_MESSAGE

				' init Previous and Next links
				Select Case boxType.ToString()
					Case Constants.MSGBOX_INBOX
						'prevMessage = Messages.GetUserInboxPreviousMessage( usr.ID, MessageID );
						'nextMessage = Messages.GetUserInboxNextMessage( usr.ID, MessageID );
						prevMessage = Messages.GetUserInboxGroupBulletinPreviousMessage(usr.ID, MessageID, DirectCast(msg.MessageType, Integer))
						nextMessage = Messages.GetUserInboxGroupBulletinNextMessage(usr.ID, MessageID, DirectCast(msg.MessageType, Integer))
						hlInboxUp.NavigateUrl = "../" + Constants.INBOX
						hlInboxDown.NavigateUrl = "../" + Constants.INBOX
						' init tabs
						ucTabs.ActiveTab = 1
						Exit Select
					Case Constants.MSGBOX_SENT
						prevMessage = Messages.GetUserOutboxPreviousMessage(usr.ID, MessageID)
						nextMessage = Messages.GetUserOutboxNextMessage(usr.ID, MessageID)
						hlInboxUp.NavigateUrl = "../" + Constants.SENT_MESSAGE
						hlInboxDown.NavigateUrl = "../" + Constants.SENT_MESSAGE

						' init tabs
						ucTabs.ActiveTab = 2
						Exit Select
					Case Constants.MSGBOX_BULLETIN
						If isGroupMode Then
							prevMessage = Messages.GetGroupPreviousBulletin(grpID, MessageID, 0, -1)
							nextMessage = Messages.GetGroupNextBulletin(grpID, MessageID, 0, -1)
							hlInboxUp.NavigateUrl = "../" + Constants.BULLETIN + "?" + Constants.GROUP_PARAM + "=" + grp.ID
							hlInboxDown.NavigateUrl = "../" + Constants.BULLETIN + "?" + Constants.GROUP_PARAM + "=" + grp.ID
							grpBlogTabs.ActiveTab = 1
						Else
							prevMessage = Messages.GetUserInboxPreviousBulletin(usr.ID, MessageID)
							nextMessage = Messages.GetUserInboxNextBulletin(usr.ID, MessageID)
							hlInboxUp.NavigateUrl = "../" + Constants.SENT_MESSAGE
							hlInboxDown.NavigateUrl = "../" + Constants.SENT_MESSAGE
							' init tabs
							ucTabs.ActiveTab = 1
						End If
						Exit Select
					Case Constants.MSGBOX_GROUP_BULLETIN
						prevMessage = Messages.GetUserGroupPreviousBulletin(usr.ID, MessageID, 0, -1)
						nextMessage = Messages.GetUserGroupNextBulletin(usr.ID, MessageID, 0, -1)
						ucTabs.ActiveTab = 1
						Exit Select
					Case Constants.MSGBOX_TRASH
						If isGroupMode AndAlso grpBlogTabs.Visible Then
							prevMessage = Messages.GetGroupPreviousBulletin(grpID, MessageID, 0, 1)
							nextMessage = Messages.GetGroupNextBulletin(grpID, MessageID, 0, 1)
							hlInboxUp.NavigateUrl = "../" + Constants.TRASH + "?" + Constants.GROUP_PARAM + "=" + grp.ID
							hlInboxDown.NavigateUrl = "../" + Constants.TRASH + "?" + Constants.GROUP_PARAM + "=" + grp.ID
							grpBlogTabs.ActiveTab = 3
						Else
							prevMessage = Messages.GetUserTrashPreviousMessage(usr.ID, MessageID, msg.MessageType)
							nextMessage = Messages.GetUserTrashNextMessage(usr.ID, MessageID, msg.MessageType)
							hlInboxUp.NavigateUrl = "../" + Constants.TRASH
							hlInboxDown.NavigateUrl = "../" + Constants.TRASH
							' init tabs
							ucTabs.ActiveTab = 3
						End If
						Exit Select
					Case Else
						' init tabs
						ucTabs.ActiveTab = 0
						grpBlogTabs.ActiveTab = 0
						Exit Select
				End Select

				initLinks(prevMessage, nextMessage)

				' init Message
				If bShowSentFromCurrUserMsg = False Then
					hlFromName.Text = msg.Sender.Name
				Else
					hlFromName.Text = sRecipientName
				End If

				litDate.Text = msg.DateSent.ToLongDateString() + ", " + msg.DateSent.ToShortTimeString()
				If msg.MessageType = Messages.MessageType.mtGroupBulletin AndAlso grpID > 0 Then
					litSubject.Text = "<a href='" + Constants.GROUP + "?" + Constants.GROUP_PARAM + "=" + grp.ID + "'>[" + grp.Name + "]</a>&nbsp;" + Server.HtmlEncode(msg.Subject)
					litBody.Text = showLinksInMessage(msg.Body, False)
				Else
					litSubject.Text = Server.HtmlEncode(msg.Subject)
					litBody.Text = showLinksInMessage(msg.Body, False)
				End If

				Select Case msg.MessageType
					Case Messages.MessageType.mtBulletin
						imgType.ImageUrl = Constants.BULLETIN_IMAGE_URL
						imgType.ToolTip = Constants.MSG_TYPE_NAME_BULLETIN
						lblTypes.Text = Constants.MSG_TYPE_NAME_BULLETIN
						Exit Select
					Case Messages.MessageType.mtGroupBulletin
						imgType.ImageUrl = Constants.GROUP_BULLETIN_IMAGE_URL
						imgType.ToolTip = Constants.MSG_TYPE_NAME_GRP_BULLETIN
						lblTypes.Text = Constants.MSG_TYPE_NAME_GRP_BULLETIN
						Exit Select
					Case Else
						imgType.ImageUrl = Constants.MESSAGE_IMAGE_URL
						imgType.ToolTip = Constants.MSG_TYPE_NAME_MESSAGE
						lblTypes.Text = Constants.MSG_TYPE_NAME_MESSAGE
						Exit Select
				End Select
			End If
		End Sub

		Private Sub initLinks(ByVal prevMessage As Message, ByVal nextMessage As Message)
			'Messages.MessageType msgTypeGroupBulletin = Messages.MessageType.mtGroupBulletin;
			Dim msgGroup As GroupBulletinMessage = Nothing

			If prevMessage <> Nothing Then
				hlPrevMessage.NavigateUrl = "../" + Constants.VIEW_MESSAGE + "?id=" + prevMessage.ID + "&" + Constants.MSGBOX_PARAM + "=" + boxType + "&" + Constants.MSG_TYPE_PARAM + "=" + DirectCast(prevMessage.MessageType, Integer)
				hlPrevMessageDown.NavigateUrl = "../" + Constants.VIEW_MESSAGE + "?id=" + prevMessage.ID + "&" + Constants.MSGBOX_PARAM + "=" + boxType + "&" + Constants.MSG_TYPE_PARAM + "=" + DirectCast(prevMessage.MessageType, Integer)

				'if ( (prevMessage.MessageType == msgTypeGroupBulletin && trUserMenu.Visible == true ) || ( isGroupMode && isUserMode && boxType != Constants.MSGBOX_TRASH))
				If (isGroupMode AndAlso isUserMode AndAlso boxType <> Constants.MSGBOX_TRASH) Then
					msgGroup = DirectCast(prevMessage, GroupBulletinMessage)
					hlPrevMessage.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + msgGroup.GroupID + "&" + Constants.USER_MODE_PARAM + "=" + isUserMode
					hlPrevMessageDown.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + msgGroup.GroupID + "&" + Constants.USER_MODE_PARAM + "=" + isUserMode
ElseIf isGroupMode AndAlso grpBlogTabs.Visible Then
					hlPrevMessage.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + grp.ID
					hlPrevMessageDown.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + grp.ID
				End If
			Else
				hlPrevMessage.Visible = False
				hlPrevMessageDown.Visible = False
				lblLineDown.Visible = False
				lblLine.Visible = False
			End If

			If nextMessage <> Nothing Then
				hlNextMessage.NavigateUrl = "../" + Constants.VIEW_MESSAGE + "?id=" + nextMessage.ID + "&" + Constants.MSGBOX_PARAM + "=" + boxType + "&" + Constants.MSG_TYPE_PARAM + "=" + DirectCast(nextMessage.MessageType, Integer)
				hlNextMessageDown.NavigateUrl = "../" + Constants.VIEW_MESSAGE + "?id=" + nextMessage.ID + "&" + Constants.MSGBOX_PARAM + "=" + boxType + "&" + Constants.MSG_TYPE_PARAM + "=" + DirectCast(nextMessage.MessageType, Integer)

				'if ( (nextMessage.MessageType == msgTypeGroupBulletin && trUserMenu != null && trUserMenu.Visible == true ) || ( isGroupMode && isUserMode && boxType != Constants.MSGBOX_TRASH ) )
				If (isGroupMode AndAlso isUserMode AndAlso boxType <> Constants.MSGBOX_TRASH) Then
					msgGroup = DirectCast(nextMessage, GroupBulletinMessage)
					hlNextMessage.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + msgGroup.GroupID + "&" + Constants.USER_MODE_PARAM + "=" + isUserMode
					hlNextMessageDown.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + msgGroup.GroupID + "&" + Constants.USER_MODE_PARAM + "=" + isUserMode
ElseIf isGroupMode AndAlso grpBlogTabs.Visible Then
					hlNextMessage.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + grp.ID
					hlNextMessageDown.NavigateUrl += "&" + Constants.GROUP_PARAM + "=" + grp.ID
				End If
			Else
				hlNextMessage.Visible = False
				lblLineDown.Visible = False
				lblLine.Visible = False
				hlNextMessageDown.Visible = False
			End If
		End Sub
		#region Web Form Designer generated code
		Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()

		End Sub
#End Region

		Protected Sub btnReply_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			Dim pageRedirect As String = Constants.SEND_MESSAGE + "?uid=" + SenderID + "&id=" + MessageID + "&action=" + Constants.MESSAGE_REPLY_ACTION
			If isGroupMode Then
				pageRedirect += "&" + Constants.GROUP_PARAM + "=" + grp.ID
			End If

			pageRedirect += "&" + Constants.MSGBOX_PARAM + "=" + boxType + "&" + Constants.MSG_TYPE_PARAM + "=" + msgType + "&" + Constants.USER_MODE_PARAM + "=" + isUserMode

			Response.Redirect(pageRedirect, False)
		End Sub

		Protected Sub btnForward_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			Dim pageRedirect As String = Constants.SEND_MESSAGE + "?id=" + MessageID + "&action=" + Constants.MESSAGE_FORWARD_ACTION
			If isGroupMode Then
				pageRedirect += "&" + Constants.GROUP_PARAM + "=" + grp.ID
			End If

			pageRedirect += "&" + Constants.MSGBOX_PARAM + "=" + boxType + "&" + Constants.MSG_TYPE_PARAM + "=" + msgType + "&" + Constants.USER_MODE_PARAM + "=" + isUserMode

			Response.Redirect(pageRedirect, False)
		End Sub

		Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			Dim usr As User = LoggedUser
			Dim msg As Message = Nothing
			If isGroupMode Then
				If ucTabs.Visible Then
					msg = Messages.GetUserGroupBulletin(usr.ID, grpID, MessageID)
				Else
					msg = Messages.GetGroupBulletin(grp.ID, MessageID)
				End If
ElseIf bIsGroupBulletin Then
				msg = Messages.GetUserGroupBulletin(usr.ID, -1, MessageID)
			Else
				msg = Messages.GetUserMessage(usr.ID, MessageID)
			End If

			If msg <> Nothing Then
				Dim isTrash As Boolean = msg.IsMarkedDeleted
				Dim MessageBox As Messages.BoxType = msg.Box
				Dim MessageType As Messages.MessageType = msg.MessageType

				If isTrash Then
					msg.Delete()
					If isGroupMode AndAlso grpBlogTabs.Visible Then
						Response.Redirect(Constants.TRASH + "?" + Constants.GROUP_PARAM + "=" + grp.ID)
					Else
						Response.Redirect(Constants.TRASH)
					End If
				Else
					msg.IsMarkedDeleted = True
					msg.Save()

					If MessageType.Equals(Messages.MessageType.mtBulletin) OrElse MessageType.Equals(Messages.MessageType.mtGroupBulletin) Then
						If isGroupMode Then
							If isUserMode Then
								' group bulletin message
								Response.Redirect(Constants.MESSAGES_GROUP_BULLETIN)
							Else
								' group bulletin message
								Response.Redirect(Constants.BULLETIN + "?" + Constants.GROUP_PARAM + "=" + grp.ID)
							End If
						Else
							' bulletin message
							Response.Redirect(Constants.BULLETIN)
						End If
					Else
						Select Case MessageBox
							Case Messages.BoxType.btInbox
								' inbox section messages
								Response.Redirect(Constants.INBOX)
								Exit Select
							Case Messages.BoxType.btOutbox
								' outbox section messages
								' outbox mail messages	
								Response.Redirect(Constants.SENT_MESSAGE)
								Exit Select
						End Select
					End If
				End If
			End If
		End Sub

		====================
		' This public property was added by conversion wizard to allow the access of a protected, autogenerated member variable Form1.
		====================
		Public ReadOnly Property Form1() As System.Web.UI.HtmlControls.HtmlForm
			Get
				Return Migrated_Form1
			End Get
		End Property
		'set { Migrated_Form1 = value; }
	End Class
End Namespace






